﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Plat.WfProcess.Business
{
    /// <summary>
    /// 审批意见类
    /// </summary>
    internal class CommentManager
    {
        private CommentRepository _commentRepository;
        private CommentRepository commentRepository
        {
            get
            {
                if (_commentRepository == null)
                {
                    _commentRepository = new CommentRepository();
                }
                return _commentRepository;
            }
        }

        internal CommentEntity Select(long commentID)
        {
            return commentRepository.SelectById(commentID.ToString());
        }

        internal IList<CommentEntity> Select(int pageIndex,
           int pageSize,
           out long allRowsCount,
           string orderBy,
           string where,
           params object[] values)
        {
            return commentRepository.Select(pageIndex, pageSize, out allRowsCount, orderBy, false, where, values);
        }

        internal IList<CommentEntity> Select(int pageIndex,
           int pageSize,
           out long allRowsCount,
           string orderBy,
           long applicationInstanceID)
        {
            string where = "ApplicationInstanceID == @0";
            return Select(pageIndex, pageSize, out allRowsCount, orderBy, where, applicationInstanceID);
        }

        #region 新增、更新和删除流程数据
        internal long Insert(CommentEntity entity)
        {
            return commentRepository.Insert(entity).CommentID;
        }

        public void Update(CommentEntity entity)
        {
            commentRepository.Update(entity);
        }

        public void Delete(long commentID)
        {
            commentRepository.Delete(commentID.ToString());
        }
        #endregion  
    }
}
